home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / WPUTS.C < prev    next >
Text File  |  1990-01-16  |  3KB  |  68 lines

  1. /**********************************************************/
  2. /* File Id.                  Wputs.C.                     */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written.             02/27/89.                    */
  5. /*                                                        */
  6. /*           (c) Copyright 1989-90 by Stan Milam          */
  7. /*                                                        */
  8. /* Comments: This function will write a string to a spec- */
  9. /* fied window with that window's saved color.  If the    */
  10. /* window is overlapped it "floated" to the top. It then  */
  11. /* becomes the active window.                             */
  12. /**********************************************************/
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <dos.h>
  18. #include "pcw.i"
  19. #include "pcwproto.h"
  20.  
  21. #define center (((wnd->lcol - wnd->ucol) / 2) - (wrklen / 2));
  22. #define wrkstr PCWRKSTR
  23.  
  24. extern char wrkstr[];
  25.  
  26. int wputs(WNDPTR *wnd, int row, int col, char str[]) {
  27.  
  28.     int far  *scrnptr;
  29.     int      page, pagesize, attr;
  30.     int      mx_rows, mx_cols, wrklen;
  31.     unsigned offset, scrnseg;
  32.  
  33.     if (!wnd) return(0);
  34.     if (!chk_video_state(&mx_rows,&mx_cols)) return(0);
  35.     if (wnd->hideflag) return(0);
  36.  
  37.     strcpy(wrkstr,str);
  38.     wrklen = strlen(wrkstr);
  39.     if (col == CENTER) col = center;
  40.     row = row + wnd->urow;
  41.     col = col + wnd->ucol;
  42.  
  43. /*****************************************************************/
  44. /* Need to put in some code to see if string will fit into window*/
  45. /* Truncate the string if neccessary.  Two cases, if string too  */
  46. /* long to fit in window, or starting in a column where it will  */
  47. /* move out of bounds.  Also need to check if the row is valid.  */
  48. /*****************************************************************/
  49.  
  50.  
  51.     if (col >= wnd->lcol) return(0);        /* Check to see if row */
  52.     if (col <= wnd->ucol) return(0);        /* Or col out of bounds */
  53.     if (row <= wnd->urow) return(0);
  54.     if (row >= wnd->lrow) return(0);
  55.     if ((wrklen + col) >= wnd->lcol)        /* If string too long then */
  56.        wrkstr[wnd->lcol - col] = '\0';      /* truncate it.            */
  57.  
  58.     re_order(wnd, NORMAL);
  59.     scrnseg = getscrnseg();
  60.     page    = wnd->page;
  61.     pagesize= getpagesize();
  62.     offset  = MK_SCRNOFF(row,col);
  63.     attr    = wnd->attr << 8;
  64.     scrnptr = (int far *)MK_FP(scrnseg,offset);
  65.     Tputs(scrnptr, (char far *) wrkstr, attr);
  66.     return(1);
  67. }
  68.